import {
    AccountParams,
    DeptListItem,
    MenuParams,
    RoleParams,
    RolePageParams,
    MenuListGetResultModel,
    DeptListGetResultModel,
    AccountListGetResultModel,
    RolePageListGetResultModel,
    RoleListGetResultModel, RoleListItem,
} from './model/systemModel';
  import { http as defHttp } from '@/utils/http/axios';
  
  enum Api {
    AccountList = '/system/getAccountList',
    IsAccountExist = '/system/accountExist',
    DeptList = '/system/getDeptList',
    setRoleStatus = '/system/setRoleStatus',
    MenuList = '/system/getMenuList',
    RolePageList = '/system/getRoleListByPage',
    GetAllRoleList = '/system/getAllRoleList',
    AddRole = '/system/addRole',
    GetPermissionTree = '/system/getPermissionTree',
  }
  
  export const getAccountList = (params: AccountParams) =>
    defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });
  
  export const getDeptList = (params?: DeptListItem) =>
    defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });
  
  export const getMenuList = (params?: MenuParams) =>
    defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });
  
  export const getRoleListByPage = (params?: RolePageParams) =>
    defHttp.post<RolePageListGetResultModel>({ url: Api.RolePageList, params });

export const AddRole = (params?: RoleListItem) =>
    defHttp.post({ url: Api.AddRole, params });

export const getAllRoleList = (params?: RoleParams) =>
    defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
  
  export const setRoleStatus = (id: number, status: string) =>
    defHttp.post({ url: Api.setRoleStatus, params: { id, status } });
  
  export const isAccountExist = (account: string) =>
    defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });
  
export const getPermissionTree = () =>
    defHttp.get({ url: Api.GetPermissionTree});
  
    